package leetCode;

import java.util.HashMap;

public class t454 {
    public static void main(String[] args) {

    }
}

class SolutionT454 {
    public int fourSumCount(int[] nums1, int[] nums2, int[] nums3, int[] nums4) {
        HashMap<Integer,Integer>map=new HashMap<>();
        int count=0;
        for (int num1:nums1){
            for (int num2:nums2){
                Integer orDefault = map.getOrDefault(num2 + num1, 0);
                map.put(num2 + num1,++orDefault );
            }
        }
        for (int num3:nums3){
            for (int num4:nums4){
                if (map.containsKey((num4+num3)*(-1))) {
                    count=count+map.get((num4+num3)*(-1));
                }
            }
        }
        return count;
    }
}